/**
 * Definition for singly-linked list.
 * type ListNode struct {
 *     Val int
 *     Next *ListNode
 * }
 */
 package Solutions
func hasCycle(head *ListNode) bool {
	if head == nil || head.Next == nil {
		return false
	}
	fastP, slowP :=  head.Next,head
	for {
        if fastP==nil{
            return false
        }
		if fastP == slowP {
			return true
		}
		if fastP.Next == nil {
			return false
		} else {
			fastP = fastP.Next.Next
		}
		slowP = slowP.Next

	}
}
